#ifndef __APP_MANAGER_API_H__
#define __APP_MANAGER_API_H__
#pragma once

struct STErrorInfo
{
	uint32_t errorCode;
	std::string errorMessage;
};

struct STAppCreateRequest
{
	std::string appname;
	std::string action;
	std::string strtemplate;
};

struct STAppCreateResponse
{
	std::vector<STErrorInfo> errorList;
	std::string index_name;
	std::string status;
	std::string request_id; 
};

struct STAppDeleteRequest
{
	std::string appname;
	std::string action;
};

struct STAppDeleteResponse
{
	std::vector<STErrorInfo> errorList;
	int32_t result;
	std::string status;
	std::string request_id; 
};

struct STAppStatusRequest
{
	std::string appname;
	std::string action;
};

struct STAppStatusResponse
{
	std::vector<STErrorInfo> errorList;
	std::string index_name;
	std::string status;
	std::string request_id; 
	int32_t pv;
	std::string doc_last_update_time;
	uint32_t total_doc_num;
	bool instance_out_of_limit;
	bool qps_out_of_limit;
	std::string name;
	std::string type;
	std::string is_multi;
	std::string is_pk;
	std::string src;
};

struct STAppListRequest
{
	std::string page;
	std::string page_size;
};

struct STAppInfo
{
	std::string id;
	std::string name;
	std::string description;
	std::string created;
};

struct STAppListResponse
{
	std::vector<STAppInfo> appLists;
	std::string total;
	std::string status;
	std::string request_id; 
};

class DLL_OPENSEARCH_API CAppManager
{
public:
	static CAppManager* getInstance();

	bool Initialize(std::string host);
	bool Destory();

	STAppCreateResponse* createApp(STAppCreateRequest *pRequest, std::string method = "GET");
	bool parseAppCreateResponse();

	STAppDeleteResponse* deleteApp(STAppDeleteRequest *pRequest, std::string method = "GET");
	bool parsedeleteAppResponse();

	STAppStatusResponse* statusApp(STAppStatusRequest *pRequest, std::string method = "GET");
	bool parsestatusAppResponse();

	STAppListResponse* listApp(STAppListRequest *pRequest, std::string method = "GET");
	bool parselistAppResponse();

	STAppCreateResponse m_appCreateResponse;
	STAppDeleteResponse m_appDeleteResponse;
	STAppStatusResponse m_appStatusResponse;
	STAppListResponse m_appListResponse;
	std::string m_strUrl;
	std::map<std::string, std::string> m_mapRequestParameter;
	std::vector<std::string> m_vecRequestParameter;
private:
	CAppManager();
	~CAppManager();
};

#endif